﻿package frEngine.shader.md5shader
{
    import baseEngine.system.*;
    import flash.display3D.*;
    import flash.events.*;
    import flash.geom.*;
    import frEngine.core.*;
    import frEngine.shader.filters.fragmentFilters.extra.*;
    import frEngine.shader.filters.vertexFilters.*;
    import frEngine.shader.registType.*;

    public class XRayShader extends Md5ShaderBase
    {
        private var _xRayCameraPosRg:FcParam;
        public var xrayFilter:XRayFilter;
        private static var pool:Array = [];

        public function XRayShader(param1:int, param2:VertexFilter, param3:XRayFilter)
        {
            super(param1, param2, param3);
            this.initXRayMaterialParams(param1);
            this.xrayFilter = param3;
            return;
        }// end function

        private function initXRayMaterialParams(param1:int) : void
        {
            this.materialParams.addFilte(new VertexNormalFilter());
            this.materialParams.depthWrite = false;
            this.materialParams.setBlendMode(EBlendType.BLEND_ADDITIVE);
            this.materialParams.depthCompare = Context3DCompareMode.ALWAYS;
            return;
        }// end function

        override protected function materialRebuilder(event:Event) : void
        {
            super.materialRebuilder(event);
            this._xRayCameraPosRg = getParam("{CamPos}", false);
            return;
        }// end function

        public function changeParams() : void
        {
            var _loc_1:Vector3D = null;
            if (this._xRayCameraPosRg)
            {
                _loc_1 = Global3D.camera.pos;
                this._xRayCameraPosRg.changeValue3(_loc_1.x, _loc_1.y, _loc_1.z);
            }
            return;
        }// end function

        public static function getInstanceFromPool(param1:int, param2:VertexFilter, param3:XRayFilter) : XRayShader
        {
            var _loc_4:XRayShader = null;
            if (pool.length == 0)
            {
                return new XRayShader(param1, param2, param3);
            }
            _loc_4 = pool.shift();
            _loc_4.materialParams.vertexFilter = param2;
            _loc_4.materialParams.fragmentFilter = param3;
            _loc_4.materialParams.skinNum = param1;
            return _loc_4;
        }// end function

        public static function disposeInstance(param1:XRayShader) : void
        {
            if (!param1)
            {
                return;
            }
            if (pool.indexOf(param1) == -1)
            {
                pool.push(param1);
            }
            return;
        }// end function

    }
}
